﻿Imports System.Data

Partial Class manage_Default
    Inherits System.Web.UI.Page
    Protected Sub GetAllUsers()
        DropDownList1.Items.Clear()
        Dim DataTable As MembershipUserCollection = Membership.GetAllUsers()
        Dim Row As MembershipUser
        Dim Odd As Boolean = False
        For Each Row In DataTable
            DropDownList1.Items.Add(Row.UserName)
        Next
        DropDownList1.Items.Add("%%")
    End Sub
    Protected Sub GetTotalRows()
        Dim dv As DataView = SQLSearch.Select(DataSourceSelectArguments.Empty)
        Dim rc = dv.Count
        If rc >= 100 Then
            lblResultCount.Text = "About " & rc & "+ results"
        ElseIf rc = 1 Then
            lblResultCount.Text = "About " & rc & " result"
        Else
            lblResultCount.Text = "About " & rc & " results"
        End If
    End Sub
    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Session("findstring") = "%" & txtFind.Text & "%"
        GetTotalRows()
    End Sub

    Protected Sub Page_LoadComplete(sender As Object, e As EventArgs) Handles Me.LoadComplete
        If DropDownList1.Items.Count = 0 Then
            GetAllUsers()
            If Roles.IsUserInRole(Context.User.Identity.Name.ToString(), "Manager") Then
                DropDownList1.Enabled = True
            Else
                DropDownList1.Enabled = False
                DropDownList1.SelectedValue = Context.User.Identity.Name.ToString()
            End If
        End If
    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        Session("IdentityName") = DropDownList1.SelectedValue
        'Response.Write(Session("IdentityName"))
    End Sub
End Class
